package cn.swu.ws.security;

import cn.swu.ws.user.UserServlet;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebFilter;
import jakarta.servlet.http.HttpFilter;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
//@WebFilter(urlPatterns = "/*")
public class allFilter extends HttpFilter {
    public void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
        // 放行不需要拦截的资源路径
        System.out.println("过滤器执行了");
        System.out.println(UserServlet.login_state);
        System.out.println(request.getServletPath());
        String  path = request.getServletPath();
        if(path.equals("/UserServlet") ||
            path.equals("/DecodeServlet")
            ){
            chain.doFilter(request, response);
        }
        if(UserServlet.login_state){
            chain.doFilter(request, response);
        }
    }
}
